/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package ejb;

import java.io.Serializable;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;

/**
 *
 * @author Gemma
 */
@Entity
@NamedQueries({
    @NamedQuery(name = "trovaMailAuth",
            query = "SELECT u.mail "
            + "FROM Utente u "
            + "WHERE u.mail LIKE :mail AND "
            + "      u.password LIKE :password"),
    @NamedQuery(name = "trovaPasswordAuth",
            query = "SELECT u.password "
            + "FROM Utente u "
            + "WHERE u.mail LIKE :mail AND "
            + "      u.password LIKE :password"),
    @NamedQuery(name = "trovaGruppoAuth",
            query = "SELECT u.gruppo "
            + "FROM Utente u "
            + "WHERE u.mail LIKE :mail AND "
            + "      u.password LIKE :password"),
    @NamedQuery(name = "trovaNomeAuth",
            query = "SELECT u.nome "
            + "FROM Utente u "
            + "WHERE u.mail LIKE :mail AND "
            + "      u.password LIKE :password"),
@NamedQuery(name = "trovaIDAuth",
            query = "SELECT u.id "
            + "FROM Utente u "
            + "WHERE u.mail LIKE :mail AND "
            + "      u.password LIKE :password"),
@NamedQuery(name = "trovaMailByID",
            query = "SELECT u.mail "
            + "FROM Utente u "
            + "WHERE u.id = :idUtente"),
    @NamedQuery(name = "trovaIDByMail",
            query = "SELECT u.id "
            + "FROM Utente u "
            + "WHERE u.mail = :mail"),
})
    
public class Utente implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private String id;
    private String nome;
    private String mail;
    private String password;
    private String gruppo;

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getNome() {
        return nome;
    }

    public void setNome(String nome) {
        this.nome = nome;
    }

    public String getMail() {
        return mail;
    }

    public void setMail(String mail) {
        this.mail = mail;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getGruppo() {
        return gruppo;
    }

    public void setGruppo(String gruppo) {
        this.gruppo = gruppo;
    }
  
    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Utente)) {
            return false;
        }
        Utente other = (Utente) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "ejb.Utente[ id=" + id + " ]";
    }

}
